<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <title>Document</title>
    <style>
        .main{
            overflow: hidden;
        }
        .item{
            padding: 10px;
            border: 1px solid #666;
            float: left;
        }
        img{
            width: 200px;
            height: 200px;
        }
    </style>
</head>
<body>
    <div class="main"></div>
    <script>
        var value = 30;
        var url = `http://47.113.104.50:3000/top/playlist/?cat=华语&limit=30&offset=${value}`;
        function http(url){
            $.ajax({
                type: "get",
                url,
                success: function (res) {
                    res.playlists.forEach(res=>{
                        var html = `
                            <div class="item">
                                <img src=${res.coverImgUrl} alt="">
                            </div>
                        `
                        $(".main").append(html);
                    })
                }
            });
        }
        http(url);
        $(window).scroll(function(){
            if(height()){
                value+=30;
                http(url);
            }
        })
        function height(){
            var toTop = $(window).scrollTop();
            var view = $(window).height();
            var allHeight = $(document).height();
            return (toTop+view)>allHeight-100?true:false;
        }
    </script>
</body>
</html>